package servlet.dao;

import java.util.List;

import org.apache.commons.dbutils.handlers.BeanListHandler;

import servlet.bean.UserBean;
import servlet.dbconnect.DBDriverFactory;

public class LoginDao {

	public boolean isLogin(UserBean userB){
		boolean isL=false;
		String strsql="SELECT * FROM TBUSER1 WHERE USERNAME=? AND USER_PSW=?";
		List<UserBean> lstUser=DBDriverFactory.getDBDriverInstance().query(strsql, new BeanListHandler<UserBean>(UserBean.class),new Object[]{userB.getUsername(),userB.getUser_psw()});
		if(lstUser!=null && lstUser.size()>0){
			isL=true;
		}
		return isL;
	}
	
	public List<UserBean> isLogin2(UserBean userB){
		
		String strsql="SELECT * FROM TBUSER1 WHERE USERNAME=? AND USER_PSW=? AND USER_ROLE=?";
		List<UserBean> lstUser=DBDriverFactory.getDBDriverInstance().query(strsql, new BeanListHandler<UserBean>(UserBean.class),new Object[]{userB.getUsername(),userB.getUser_psw(),userB.getUser_role()});
		
		return lstUser;
	}
}
